package com.tensquare.base.service;

import com.tensquare.base.dao.LabelDao;
import com.tensquare.base.pojo.Label;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import util.IdWorker;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description
 * @Date 2021/3/19 13:39
 */
@Service
@Transactional
public class LabelService {
    @Resource
    private LabelDao labelDao;

    @Resource
    private IdWorker idWorker;

    public List<Label> findAll() {
        return labelDao.list();
    }

    public Label findById(String id) {
        return labelDao.getById(id);
    }

    public void save(Label lable) {
        lable.setId(idWorker.nextId() + "");
        labelDao.save(lable);
    }

    public void update(Label lable) {
        labelDao.save(lable);
    }

    public void deleteById(String id) {
        labelDao.removeById(id);
    }

}
